package com.gxa.zhonglong.controller;

import com.gxa.zhonglong.common.JsonResult;
import com.gxa.zhonglong.pojo.CheckIoVO;
import com.gxa.zhonglong.pojo.InventoryOut;
import com.gxa.zhonglong.service.*;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpRequest;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;
import java.util.List;
import java.util.Map;
import java.util.Set;

@Api("配货出库的接口")
@CrossOrigin
@RestController
@RequestMapping("/checkio")
public class CheckIoVOController {
    @Autowired
    CheckIoVOService checkIoVOService;
    @Autowired
    IoGetService ioGetService;
    @Autowired
    InventoryOutService inventoryOutService ;
    @Autowired
    StoreBarterService storeBarterService=null;
    @Autowired
    GoodsTypeService goodsTypeService=null;

    @GetMapping("selectAll")
    public Map<String,Object> selectAll(@RequestParam("page") Integer page,@RequestParam("size") Integer size){
        Map<String, List<CheckIoVO>> stringListMap = checkIoVOService.selectAll(page, size);
        JsonResult jsonResult = new JsonResult();
        jsonResult.setCode("1");
        jsonResult.setData(stringListMap);
        return jsonResult.getDataMap();

    }
    @ApiOperation(value = "根据各条件来查询视图")
    @PostMapping("/selectByCodition")
   /* @ApiImplicitParams({
            @ApiImplicitParam(name = "inventoryOut",value = "配货出库对象",dataType = "InventoryOut",paramType = "body")
    })*/
    public  Map<String,Object> selectByCodition(@RequestBody InventoryOut inventoryOut){


        System.out.println("-------------");
        System.out.println(inventoryOut);
        Map<String, List<CheckIoVO>> stringListMap = checkIoVOService.selectByCondition(inventoryOut);
        JsonResult jsonResult = new JsonResult();
        jsonResult.setCode("1");
        jsonResult.setData(stringListMap);
        return jsonResult.getDataMap();
    }

    @ApiOperation(value = "删除采购订单视图")
    @GetMapping("/delet")
    @ApiImplicitParams({
            @ApiImplicitParam(name="num",value = "单据编号",paramType = "String")
    })
    public Map delete(String num){
        ioGetService.delete(num);
        inventoryOutService.delete(num);
        JsonResult jsonResult = new JsonResult();
        jsonResult.setCode("1");
        jsonResult.setMsg("删除成功");
        return  jsonResult.getDataMap();
    }
    @ApiOperation("查询全部门店的方法")
    @PostMapping("/selectAllStore")
    public Map selectAllStore(){
        List<String> stringList = storeBarterService.selectAllStore();
        return new JsonResult("1","成功",stringList).getDataMap();
    }



    @ApiOperation("查询门店下柜台的方法")
    @PostMapping("/selectCounter")
    @ApiImplicitParams({
            @ApiImplicitParam(value = "门店名字(必须)",name = "CName",required = true),
    })
    public Map selectCounter(String CName) throws Exception {
        List<String> stringList = storeBarterService.selectCounter(CName);
        return new JsonResult("1","成功",stringList).getDataMap();
    }


    @ApiOperation("获得全部商品类型名字")
    @PostMapping("/getNameList")
    public Map getNameList()  {
        List<String> nameList = goodsTypeService.getNameList();
        return new JsonResult("1","成功",nameList).getDataMap();
    }




}
